#include <algorithm>
#include <cstdio>
#include <queue>
#include <vector>

using std::make_pair;

typedef std::pair<int, int> PII;
typedef long long LL;

int const N = 1e5 + 5, day = 1e5;
int n, m, k, sum, s[N], a[N], c[N], x[N], used[N];
bool vis[N];
LL ans[N];

std::queue<int> q;
std::vector<int> veg[N];
std::priority_queue<PII, std::vector<PII>, std::greater<PII> > small;
std::priority_queue<PII, std::vector<PII>, std::less<PII> > great;

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("P3826 [NOI2017]蔬菜.in", "r", stdin);
  freopen("P3826 [NOI2017]蔬菜.out", "w", stdout);
#endif
#endif

  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d%d%d", a + i, s + i, c + i, x + i);
    if (x[i] == 0)
      veg[day].push_back(i);
    else
      veg[std::min(day, (c[i] + x[i] - 1) / x[i])].push_back(i);
  }
  for (int i = day; i; --i) {
    for (auto &j : veg[i]) great.push(make_pair(a[j] + s[j], j));
    if (great.empty()) continue;
    for (int lim = m; lim && !great.empty(); great.pop()) {
      int id = great.top().second, val = great.top().first;
      if (vis[id]) {
        LL rest = c[id] - used[id] - 1ll * (i - 1) * x[id];
        int delta = std::min((LL)lim, rest);
        ans[day] += 1ll * delta * val, lim -= delta, used[id] += delta;
        if (used[id] != c[id]) q.push(id);
      } else {
        vis[id] = true;
        ans[day] += val;
        lim--, used[id]++;
        if (c[id] != 1) great.push(make_pair(a[id], id));
      }
    }
    while (!q.empty()) {
      great.push(make_pair(a[q.front()], q.front())), q.pop();
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (used[i] == 1)
      small.push(make_pair(s[i] + a[i], i));
    else if (used[i] != 0)
      small.push(make_pair(a[i], i));
    sum += used[i];
  }
  for (int i = day - 1; i; --i) {
    ans[i] = ans[i + 1];
    if (sum <= m * i) continue;
    for (int lim = sum - m * i; lim && !small.empty();) {
      int id = small.top().second, val = small.top().first;
      small.pop();
      if (used[id] == 1) {
        used[id]--, lim--;
        ans[i] -= val;
      } else {
        int delta = std::min(lim, used[id] - 1);
        used[id] -= delta, lim -= delta;
        ans[i] -= 1ll * val * delta;
        if (used[id] == 1)
          small.push(make_pair(a[id] + s[id], id));
        else
          small.push(make_pair(a[id], id));
      }
    }
    sum = m * i;
  }
  for (int i = 1, tmp; i <= k; ++i) {
    scanf("%d", &tmp);
    printf("%lld\n", ans[tmp]);
  }
  return 0;
}